// pages/home/examine/examine.js
const globalIp = getApp().globalData.userIp
Page({
  /**
   * 页面的初始数据
   */
  data: {
    screen:"审核状态",
    screenDown: {screenDown:["全部","生效Y","待审O","失效N"],screen:0},
    screenFlag: false,//控制综合下拉框是否显示
    screenColor: false,
    nameCall: '精确搜索',
    nameColor: false,
    nameFlag: false,
    info: "",

    pageIndex:1,
    pageSize:8,
    total: 0,
    list: []
  },

  screenShow: function () {//综合下拉
    this.setData({
      screenFlag : !this.data.screenFlag,
      nameFlag: false,
      nameColor: false
    })
  },

  nameShow: function () {//综合下拉
    this.setData({
      nameFlag : !this.data.nameFlag,
      screenFlag: false,
      screenColor: false,
    })
  },

  screenChoice:function(e){//综合下拉选择子项
    this.setData({
      screen: e.currentTarget.dataset.item,
      "screenDown.screen": e.currentTarget.dataset.index,
      screenFlag: false,
      screenColor: true,
    })
    console.log(this.data)
    this.getProject()
  },

  getInputValue:function(e) {
    this.setData({
      info: e.detail.value
    })
  },

  selectData: function(){
    this.getProject();
  },

  trueIndex: function(e){
    wx.navigateTo({
      url: '../examineindex/examineindex?LineNum='+e.currentTarget.dataset.num,
    })
  },

  // 统一请求
  getProject: function() {
    let that = this;
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    var length = 0;
    wx.request({
      url: globalIp + 'home/queryUser',
      data: {
        userName: that.data.info || '',
        openId: that.data.openId || wx.getStorageSync('userInfo').openid,
        lineStatus: parseInt(that.data.screenDown.screen) || 0
      },
      header: {
        'content-type': 'application/json'
      },
      method: 'POST',
      success: function(res) {
        if (res.data.jsonObject) {
          that.setData({
            list: res.data.jsonObject
          })
        } 
      },
      fail: function(res) {
        wx.showToast({
          title: '请返回上一页面，重新请求',
          icon: 'none',
          duration: 2000,
        })
      },
      complete: function(res) {
        setTimeout(() => {
          wx.hideLoading()
        }, 15 * length)
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // this.getProject();
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getProject();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  }
})